package exception;

public class TryCatchDemo2 {
    public static void main(String[] args) {

        String str = "abcdef";
        System.out.println("程序开始执行了");
        try{
        System.out.println(str.length());
        System.out.println(str.charAt(5));
        System.out.println(Integer.parseInt(str));
        System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!");
        }catch (NullPointerException | StringIndexOutOfBoundsException e){
            System.out.println("出现了空指针异常或者字符串索引越界异常");
        }catch (Exception e){
            System.out.println("出现了未知异常");
        }
        System.out.println("程序结束了");
    }
}
